package schoolWork;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: tao
 * Date: 2023-11-13
 * Time: 15:00
 */
interface Shape {
    double getLength();
}
//长方形
class Rectangle implements Shape {
    double x;//长
    double y;//宽
    public Rectangle(double x, double y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public double getLength() {
        return x * y;
    }
}
//圆形
class Circle implements Shape {
    double r;
    public Circle(double r) {
        this.r = r;
    }
    @Override
    public double getLength() {
        return 2 * 3.14 * r;
    }
}
public class Test4 {
    public static void main(String[] args) {
        Shape shape1 = new Rectangle(2,3);
        System.out.println(shape1.getLength());
        Shape shape2 = new Circle(3);
        System.out.println(shape2.getLength());
    }
}
